package com.airline.form;

import java.rmi.RemoteException;
import java.util.ArrayList;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.ActionMapping;
import org.apache.struts.util.LabelValueBean;
import org.apache.struts.validator.ValidatorForm;

import com.airline.beans.Customer;
import com.airline.connection.AirlineSystemServiceProxy;

public class EditCustomerForm extends ValidatorForm{ 
	Customer cust = null;
	ArrayList stateList = new ArrayList();
	

	public EditCustomerForm() {
		cust = new Customer();
		
		
		stateList.add(new LabelValueBean("CA","CA"));
		stateList.add(new LabelValueBean("MI","MI"));
		stateList.add(new LabelValueBean("KS","KS"));
		stateList.add(new LabelValueBean("UT","UT"));
		stateList.add(new LabelValueBean("MO","MO"));
		stateList.add(new LabelValueBean("TN","TN"));
	}
	public ArrayList getStateList() {
		return stateList;
	}
	public void setStateList(ArrayList stateList) {
		this.stateList = stateList;
	}
	public Customer getCust() {
		return cust;
	}

	public void setCust(Customer cust) {
		this.cust = cust;
	}

	String error = null;
	
	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}
	//@Override
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		
		HttpSession httpsess = request.getSession();
		Customer cust = (Customer) httpsess.getAttribute("customer");
		AirlineSystemServiceProxy proxy = new AirlineSystemServiceProxy();
		try {
			cust = proxy.getCustomer(cust.getPersonID());
			this.cust=cust;
			httpsess.setAttribute("customer",cust);
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

}
